package com.feather.common.converter.simple.fieldassignment;

import java.lang.reflect.Field;

import com.feather.common.converter.FieldAssignment;
import com.feather.common.util.ClassUtil;

/**
 * @author flogyin
 */
public class String_Character implements FieldAssignment {
	@Override
	public Object assign(Object value, Object obj, Field field) {
		Character c = null;
		String str = (String) value;
		if (value != null && str.length() > 0) {
			c = Character.valueOf(str.charAt(0));
		} else {
			if (char.class.getName().equals(field.getType().getName()))
				c = 0;
		}

		ClassUtil.set(obj, field, c);
		return null;
	}
}
